package com.zero.system.service.Impl;

import com.zero.system.entity.Company;
import com.zero.system.mapper.CompanyMapper;
import com.zero.system.service.CompanyService;
import com.zero.system.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@Service
public class CompanyServiceImpl implements CompanyService {
    @Resource
    private CompanyMapper companyMapper;

    @Override
    public PageBean<Company> queryPage(Map<String, Object> paramMap) {
        PageBean<Company> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));
        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<Company> datas = companyMapper.queryList(paramMap);
        pageBean.setDatas(datas);
        Integer totalsize = companyMapper.getCount(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;
    }

    @Override
    public Integer getCount(Map<String, Object> paramMap) {
        return companyMapper.getCount(paramMap);
    }

    @Override
    public int add(Company models) {
        return companyMapper.add(models);
    }

    @Override
    public Company findById(Integer id) {
        return companyMapper.findById(id);
    }

    @Override
    public int delete(List<Integer> ids) {
        return companyMapper.delete(ids);
    }

    @Override
    public int update(Company models) {
        return companyMapper.update(models);
    }

    @Override
    public Company findByName(String name) {
        return companyMapper.findByName(name);
    }

    @Override
    public List<Company> findAll() {
        return companyMapper.findAll();
    }
}
